package com.situ.stmall.front.controller;

import com.situ.stmall.front.entity.Goods;
import com.situ.stmall.front.service.GoodsService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/goods")
@AllArgsConstructor
public class GoodsController {

    private GoodsService goodsService;
    @GetMapping
    public String get(Integer id, Model model){
        //查询当前商品的详情信息
        Goods goods = goodsService.getById(id);
        //传递数据到模板中
        model.addAttribute("goods",goods);
        return "goods";
    }
}
